package org.jeecg.modules.crm.service.impl;

import org.jeecg.modules.crm.entity.PaymentVoucher;
import org.jeecg.modules.crm.entity.PaymentVoucherNote;
import org.jeecg.modules.crm.entity.PaymentVoucherDetail;
import org.jeecg.modules.crm.mapper.PaymentVoucherNoteMapper;
import org.jeecg.modules.crm.mapper.PaymentVoucherDetailMapper;
import org.jeecg.modules.crm.mapper.PaymentVoucherMapper;
import org.jeecg.modules.crm.service.IPaymentVoucherService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: Payment Voucher
 * @Author: jeecg-boot
 * @Date:   2025-04-30
 * @Version: V1.0
 */
@Service
public class PaymentVoucherServiceImpl extends ServiceImpl<PaymentVoucherMapper, PaymentVoucher> implements IPaymentVoucherService {

	@Autowired
	private PaymentVoucherMapper paymentVoucherMapper;
	@Autowired
	private PaymentVoucherNoteMapper paymentVoucherNoteMapper;
	@Autowired
	private PaymentVoucherDetailMapper paymentVoucherDetailMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		paymentVoucherNoteMapper.deleteByMainId(id);
		paymentVoucherDetailMapper.deleteByMainId(id);
		paymentVoucherMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			paymentVoucherNoteMapper.deleteByMainId(id.toString());
			paymentVoucherDetailMapper.deleteByMainId(id.toString());
			paymentVoucherMapper.deleteById(id);
		}
	}
	
}
